package com.jk.bgmainconsumer.controller;

import com.jk.bgmainconsumer.entity.*;
import com.jk.bgmainconsumer.service.GoodsConsummerService;
import com.jk.bgmainconsumer.utils.OSSUtil;
import com.jk.damaicommon.wlentity.SessionSiteEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("goodsConsummer")
public class GoodsConsummerController {
    @Autowired
    private GoodsConsummerService goodsConsummerService;

    /**
     * 查全部商品
     * @param goods
     * @return
     */
    @RequestMapping("queryGoodsMap")
    public HashMap<String,Object> queryGoodsMap(GoodsEntity goods){
        return goodsConsummerService.selectAllGoods(goods);
    }

    /**
     * 下架
     * @param goodsId
     */
    @RequestMapping("downGoods")
    public void downGoods(Integer goodsId){
        goodsConsummerService.downGoods(goodsId);
    }
    @RequestMapping("upGoods")
    public void upGoods(Integer goodsId){
        goodsConsummerService.upGoods(goodsId);
    }

    @RequestMapping("selectOneGoods")
    public GoodsEntity selectOneGoods(Integer goodsId){
        return goodsConsummerService.selectOneGoods(goodsId);
    }
    /**
    *  @方法描述 (查看详情)
     * @Author 王乐
     * @Description //TODO 
     * @Date  2021/9/6 
     * @Param [goodsId]
     * @return com.jk.bgmainconsumer.entity.GoodsEntity
     **/
    @RequestMapping("getGoodsById")
    public GoodsDetailEntity getGoodsById(Integer goodsId){
        return goodsConsummerService.getGoodsById(goodsId);
    }
    /**
    *  @方法描述 (城市动态下拉)
     * @Author 王乐
     * @Description //TODO 
     * @Date  2021/9/6 
     * @Param []
     * @return java.util.List<com.jk.bgmainconsumer.entity.CityEntity>
     **/
    @RequestMapping("getCitySelect")
    public List<CityEntity> getCitySelect(){
        return goodsConsummerService.getCitySelect();
    }
    /**
    *  @方法描述 (类型动态下拉)
     * @Author 王乐
     * @Description //TODO 
     * @Date  2021/9/6 
     * @Param []
     * @return java.util.List<com.jk.bgmainconsumer.entity.GoodsTypeEntity>
     **/
    @RequestMapping("getTypeSelect")
    public List<GoodsTypeEntity> getTypeSelect(){
        return goodsConsummerService.getTypeSelect();
    }
    /**
    *  @方法描述 (系列活动动态下拉)
     * @Author 王乐
     * @Description //TODO 
     * @Date  2021/9/6 17:13
     * @Param []
     * @return java.util.List<com.jk.bgmainconsumer.entity.GoodsActiveEntity>
     **/
    @RequestMapping("getActiveSelect")
    public List<GoodsActiveEntity> getActiveSelect(){
        return goodsConsummerService.getActiveSelect();
    }
    /**
    *  @方法描述 (图片)
     * @Author 王乐
     * @Description //TODO 
     * @Date  2021/9/9 0:39
     * @Param [imgfile]
     * @return java.util.HashMap<java.lang.String,java.lang.String>
     **/
    @RequestMapping("upload")
    public HashMap<String ,String> upload(MultipartFile imgfile) throws Exception {
        String s = OSSUtil.upload2oss(imgfile);
        HashMap<String ,String> map =  new HashMap<String, String>();
        map.put("url",s);
        return map;
    }
    /**
    *  @方法描述 (新增商品)
     * @Author 王乐
     * @Description //TODO 
     * @Date  2021/9/9 0:48
     * @Param [goods]
     * @return void
     **/
    @RequestMapping("addGoods")
    public void addGoods(GoodsDetailEntity goods){
        goodsConsummerService.addGoods(goods);
    }

    /**
     * 回收站查询
     */
    @RequestMapping("recycleSelectMap")
    public HashMap<String,Object> recycleSelectMap(GoodsEntity goods){
        return goodsConsummerService.recycleSelectMap(goods);
    }
    /**
     * 彻底删除
     */
    @RequestMapping("deleteThisGoods")
    public void deleteThisGoods(Integer goodsId){
        goodsConsummerService.deleteThisGoods(goodsId);
    }
    /**
    *  @方法描述 (获取配送方式)
     * @Author 王乐
     * @Description //TODO 
     * @Date  2021/9/12 10:40
     * @Param [goods]
     * @return void
     **/
    @RequestMapping("getDistr")
    public String getDistr(){
        return goodsConsummerService.getDistr();
    }
    /**
     * 添加系列活动
     */
    @RequestMapping("addActive")
    public void addActive(ActiveEntity activeEntity){
        goodsConsummerService.addActive(activeEntity);
    }
    /**
    *  @方法描述 (座位管理场次列表)
     * @Author 王乐
     * @Description //TODO 
     * @Date  2021/9/21 6:44
     * @Param []
     * @return java.util.List<com.jk.damaicommon.wlentity.SessionSiteEntity>
     **/
    @RequestMapping("getSessionList")
    public List<SessionSiteEntity> getSessionList(SessionSiteEntity sessionSite){
        List<SessionSiteEntity> list = goodsConsummerService.getSessionList(sessionSite);
        return list;
    }
    /**
    *  @方法描述 (档次动态下拉)
     * @Author 王乐
     * @Description //TODO 
     * @Date  2021/9/21 10:26
     * @Param [id]
     * @return java.util.List<com.jk.bgmainconsumer.entity.GoodsLeaveEntity>
     **/
    @RequestMapping("getLeaveSelect")
    public List<GoodsLeaveEntity> getLeaveSelect(Integer id){
        List<GoodsLeaveEntity> list = goodsConsummerService.getLeaveSelect(id);
        return list;
    }
    /**
    *  @方法描述 (提交座位表)
     * @Author 王乐
     * @Description //TODO 
     * @Date  2021/9/21 13:26
     * @Param [site]
     * @return void
     **/
    @RequestMapping("saveSite")
    public void saveSite(SessionSiteEntity site){
        goodsConsummerService.saveSite(site);
    }
    /**
    *  @方法描述 (获取座位信息)
     * @Author 王乐
     * @Description //TODO 
     * @Date  2021/9/21 14:08
     * @Param [id]
     * @return java.lang.String
     **/
    @RequestMapping("getSiteInfo")
    public String getSiteInfo(Integer id){
        return goodsConsummerService.getSiteInfo(id);
    }

}
